//
//  GGTableView.m
//  ggtool
//
//  Created by engfei on 2017/5/1.
//  Copyright © 2017年 GaiGai. All rights reserved.
//

#import "GGCalendarTableView.h"
#import "GGCalendarCell.h"


@interface GGCalendarTableView ()<UITableViewDelegate, UITableViewDataSource>

@end


@implementation GGCalendarTableView


static NSString * const GGCalendarCellID = @"GGCalendarCell";
static NSString * const GGCalendarHeaderViewID = @"GGCalendarHeaderView";

- (instancetype)initWithFrame:(CGRect)frame style:(UITableViewStyle)style {
    if (self = [super initWithFrame:frame style:style]) {
        [self setInitialize];
    }
    return self;
}

- (instancetype)init {
    if (self = [super init]) {
        
    }
    return self;
}


- (void)setInitialize {
    
    self.delegate = self;
    self.dataSource = self;
    
    [self registerClass:NSClassFromString(GGCalendarCellID) forCellReuseIdentifier:GGCalendarCellID];
    [self registerClass:NSClassFromString(GGCalendarHeaderViewID) forHeaderFooterViewReuseIdentifier:GGCalendarHeaderViewID];
    
}

#pragma mark - UITableViewDataSource

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 8;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    GGCalendarCell *cell = [tableView dequeueReusableCellWithIdentifier:GGCalendarCellID];
    
    cell.row = indexPath.section;
    
//    cell.textLabel.text = [NSString stringWithFormat:@"%zd", indexPath.section];
    
    return cell;
    
    
}


#pragma mark - UITableViewDelegate

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [self tableView:tableView cellForRowAtIndexPath:indexPath];
    if ([cell isKindOfClass:[GGCalendarCell class]]) {
        GGCalendarCell *calendarCell = (GGCalendarCell *)cell;
        return calendarCell.cellHeight;
    }
    return 44.0f;
    
}



- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    
    
    GGCalendarHeaderView *view = [tableView dequeueReusableHeaderFooterViewWithIdentifier:GGCalendarHeaderViewID];
    view.offsetYM = section;
    
    return view;
    
}


- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 35.0f;
}


- (void)showAnimation:(BOOL)aniamtion {
    [kKeyWindow addSubview:self];
    
    
    
}






@end
